tsset dyadid year

* Table 1
quietly xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year , fe robust cluster(dyadid)
su lnfdiinstock dtt dttage bit bitage hostgdptotln hostgdppcln  hostinflln hosttrade rta if e(sample)

* Table 2
* FE static, all countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year , fe robust cluster(dyadid)
* FE dynamic, all countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year , fe robust cluster(dyadid)
* GMM, treaty age, all countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year , robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* Table 3
* FE static, developed source countries only, 1982-1992, mirroring Blonigen and Davies (2005)
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if fdiinstock_oecd_reporting==1 & repdevelop==1 & year>=1982 & year<=1992, fe robust cluster(dyadid)
* FE dynamic, developed source countries only, 1982-1992, mirroring Blonigen and Davies (2005)
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if fdiinstock_oecd_reporting==1 & repdevelop==1 & year>=1982 & year<=1992, fe robust cluster(dyadid)
* GMM, treaty age, developed source countries only, 1982-1992, mirroring Blonigen and Davies (2005), maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if fdiinstock_oecd_reporting==1 & repdevelop==1 & year>=1982 & year<=1992, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, developed source countries only, 1985-2000, mirroring Egger et al. (2006)
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if fdiinstock_oecd_reporting==1 & repdevelop_Egger==1 & year>=1985 & year<=2000, fe robust cluster(dyadid)
* FE dynamic, developed source countries only, 1985-2000, mirroring Egger et al. (2006)
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if fdiinstock_oecd_reporting==1 & repdevelop_Egger==1 & year>=1985 & year<=2000, fe robust cluster(dyadid)
* GMM, treaty age, developed source countries only, 1985-2000, mirroring Egger et al. (2006), maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if fdiinstock_oecd_reporting==1 & repdevelop_Egger==1 & year>=1985 & year<=2000, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, excluding non-reporting countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if   fdiinstock_reporting==1 , fe robust cluster(dyadid)
* FE dynamic, excluding non-reporting countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if  fdiinstock_reporting==1 , fe robust cluster(dyadid)
* GMM, treaty age, excluding non-reporting countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if  fdiinstock_reporting==1 , robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, developing host countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0, fe robust cluster(dyadid)
* FE dynamic, developing host countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==0, fe robust cluster(dyadid)
* GMM, treaty age, developing host countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==0, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, developed source countries, developing host countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0 & repdevelop==1, fe robust cluster(dyadid)
* FE dynamic, developed source countries, developing host countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==1 & repdevelop==1, fe robust cluster(dyadid)
* GMM, treaty age, developed source countries, developing host countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==1 & repdevelop==1, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, middle-income developing host countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0 & hostmiddle==1, fe robust cluster(dyadid)
* FE dynamic, middle-income developing host countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==0  & hostmiddle==1, fe robust cluster(dyadid)
* GMM, treaty age, middle-income developing host countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==0  & hostmiddle==1, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, low-income developing host countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0 & hostlow==1, fe robust cluster(dyadid)
* FE dynamic, low-income developing host countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==0  & hostlow==1, fe robust cluster(dyadid)
* GMM, treaty age, low-income developing host countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==0 & hostlow==1, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, developing host countries, excluding resource-intensive countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0 & resint==0, fe robust cluster(dyadid)
* FE dynamic, developing host countries, excluding resource-intensive countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==0 & resint==0, fe robust cluster(dyadid)
* GMM, treaty age, developing host countries, excluding resource-intensive countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==0 & resint==0, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond

* FE static, developing host countries, excluding transition countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year  if hostdevelop==0 & trans==0, fe robust cluster(dyadid)
* FE dynamic, developing host countries, excluding transition countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta bit  dtt i.year   if hostdevelop==0 & trans==0, fe robust cluster(dyadid)
* GMM, treaty age, developing host countries, excluding transition countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year  if hostdevelop==0 & trans==0, robust maxldep(6) maxlags(6) pre(dttage bitage, endog )
estat abond


*** Further robustness checks

** Different lag-length for instruments
* no maximum length
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year , robust pre(dttage bitage, endog )
estat abond
* maximum length 4
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year , robust maxldep(4) maxlags(4) pre(dttage bitage, endog )
estat abond


** Testing for non-linear effect of treaty age
* FE static, all countries
xi: xtreg  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta dttage dttage2 bitage i.year , fe robust cluster(dyadid)
* FE dynamic, all countries
xi: xtreg  lnfdiinstock  l.lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade rta dttage dttage2 bitage i.year , fe robust cluster(dyadid)
* GMM, treaty age, all countries, maximum lag length 6
xi: xtabond  lnfdiinstock  hostgdptotln hostgdppcln  hostinflln hosttrade  rta i.year , robust maxldep(6) maxlags(6) pre(dttage dttage2 bitage, endog )

